﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BitPortal.Business;
using BitPortal.Models;
using BitPortal.Utils;

namespace BitPortal.Modules.NewsScroller
{
    public partial class NewsScroller : Controls.BaseUserControl
    {
        public List<Article> ListArticle;
        public int VisibleArticle = 4;
        public bool EnableScroll = true;

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (!this.Page.ClientScript.IsStartupScriptRegistered("Jcarousel"))
            {
                this.Page.ClientScript.RegisterClientScriptInclude("Jcarousel", "/Scripts/jcarousellite_1.0.1c4.js");
            }
            this.ltrTitle.Text = ReferenceModule.GetModuleConfig("Header").ToString();
            bool? IsHot = Convert.ToBoolean(ReferenceModule.GetModuleConfig("IsHot")) ? (bool?)true : null;
            int NumberOfArticle = ReferenceModule.GetModuleConfig("NumberOfArticles").ToInt32TryParse();
            VisibleArticle = ReferenceModule.GetModuleConfig("VisibleArticle").ToInt32TryParse();
            EnableScroll = Convert.ToBoolean(ReferenceModule.GetModuleConfig("EnableScroll"));
            ListArticle = ArticleBLL.GetByCondition<Int64>(isApproved: true, isEnabled: true, isHot: IsHot, start: 0, limit: NumberOfArticle).ToList();
            RptArticles.DataSource = ListArticle;
            RptArticles.DataBind();
        }
    }
}